<template>
  <div class="department" id="department">
    <!-- 左侧部门管理 -->
    <div class="structureTree" v-if="treelength">
      <div class="structureTree_title">
        <div>组织机构</div>
        <div>
          <el-checkbox v-model="checked" @change="see()">查看下级</el-checkbox>
        </div>
      </div>
      <tree
        :treeData="treeData"
        :checkData="checkData"
        nodeKey="fCompanyid"
        @getTreeInfo="handleNodeClick"
        :defaultProps="defaultProps"
      >
      </tree>
    </div>
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 机构名称 -->
      <el-breadcrumb :title="showName"></el-breadcrumb>
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left" style="width: 100%">
          <el-select
            class="selectBhz"
            v-model="getList.fQualitygridclass"
            placeholder="选择质量网格类别"
            @change="yj_searchForm(getList)"
            style="width: 160px"
          >
            <el-option
              v-for="v in engineeringList"
              :key="v.fItemName"
              :label="v.fItemName"
              :value="v.fItemValue"
            >
            </el-option>
          </el-select>

          <input type="text" placeholder="责任人" v-model="getList.keyWord" />
          <el-button
            type="primary"
            icon="el-icon-search"
            size="small"
            @click="yj_searchForm(getList)"
            >查询</el-button
          >
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button
              type="primary"
              icon="el-icon-refresh"
              size="small"
              @change="yj_searchForm(getList)"
            >
            </el-button>
            <el-button
              type="primary"
              v-if="yj_view"
              icon="el-icon-search"
              size="small"
              @click="editText(fId)"
              >查看
            </el-button>
            <el-button
              type="primary"
              v-if="yj_delete"
              icon="el-icon-delete"
              size="small"
              @click="yj_delForm(fId)"
              >删除
            </el-button>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="small"
              @click="yj_logoff()"
              >停用
            </el-button>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <div class="text_table">
        <tableData
          :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'"
          :config="table_config"
          :dataList="tableData"
          :loading="loading"
          @selection-change="selectionChange"
          @sort-change="sortChange"
          @click-change="rowChange"
          @ClickOnLine="yj_viewForm"
          :page="getList.page"
          :pageSize="getList.pageSize"
        />
        <pagination
          v-if="navigatepageNums > 1"
          :info="queryCriteriaData"
          :treelength="treelength"
          :total="queryCriteriaData.total"
          :pageNum.sync="getList.page"
          :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)"
        />
      </div>
      <!--弹框-->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible"
          v-loading="loadingEditDialog"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div
              style="
                overflow-y: auto;
                margin-bottom: 20px;
                height: calc(100% - 31px);
                padding-top: 5px;
              "
            >
              <div class="baseTitle">质量管理责任人</div>
              <div
                class="publicForm"
                style="height: calc(100% - 80px); overflow-y: auto"
              >
                <publicForm
                  ref="publicForm0"
                  lableWidth="95px"
                  :formObj="formObjShow"
                  :formData="formData"
                >
                </publicForm>
              </div>
              <div style="height: 50px"></div>
            </div>
          </div>
        </el-dialog>
      </div>
      <!--巡查弹框--列表-->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_xc"
          v-loading="loadingEditDialog_xc"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div
              style="
                overflow-y: auto;
                margin-bottom: 20px;
                height: calc(100% - 31px);
                padding-top: 5px;
              "
            >
              <tableData
                :height="navigatepageNums_xc > 1 ? 'calc(100% - 50px)' : '100%'"
                :config="table_config_xc"
                :dataList="tableData_xc"
                :loading="loading"
                @click-change="rowChange_xc"
                @ClickOnLine="yj_viewForm_xc"
                :page="getList_xc.page"
                :pageSize="getList_xc.pageSize"
              />
              <pagination
                v-if="navigatepageNums_xc > 1"
                :info="queryCriteriaData_xc"
                :treelength="treelength"
                :total="queryCriteriaData_xc.total"
                :pageNum.sync="getList_xc.page"
                :limit.sync="getList_xc.pageSize"
                @pagination="getXcList(getList_xc)"
              />
            </div>
          </div>
        </el-dialog>
      </div>
      <!--巡查弹框 查看 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_xcLook"
          v-loading="loadingEditDialog_xcLook"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div style="overflow-y: auto; margin-bottom: 20px">
              <div class="baseTitle">质量巡查信息</div>
              <div class="publicForm" style="height: 285px">
                <publicForm
                  ref="publicForm0"
                  lableWidth="115px"
                  :formObj="formObjShow_xc"
                  :formData="formData_xc"
                  :timestamp="formData_xc.fPatrolfileurl"
                  :fileList="fHandlefileList_xc"
                >
                </publicForm>
              </div>

              <div class="baseTitle">巡查信息签收</div>
              <div class="publicForm" style="height: 80px">
                <publicForm
                  ref="publicForm1"
                  lableWidth="115px"
                  :formObj="examineShow_xc"
                  :formData="formData_xc"
                >
                </publicForm>
              </div>
              <div class="baseTitle">整改信息回复</div>
              <div class="publicForm" style="height: 120px">
                <publicForm
                  ref="publicForm1"
                  lableWidth="115px"
                  :formObj="rectificationShow_xc"
                  :formData="formData_xc"
                  :timestamp="formData_xc.fCompletionfile"
                  :fileList="fCompletionfilelist_xc"
                >
                </publicForm>
              </div>
              <div style="height: 50px"></div>
            </div>
          </div>
        </el-dialog>
      </div>
      <!--监督指令弹框--列表-->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_jd"
          v-loading="loadingEditDialog_jd"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div
              style="
                overflow-y: auto;
                margin-bottom: 20px;
                height: calc(100% - 31px);
                padding-top: 5px;
              "
            >
              <tableData
                :height="navigatepageNums_jd > 1 ? 'calc(100% - 50px)' : '100%'"
                :config="table_config_jd"
                :dataList="tableData_jd"
                :loading="loading"
                @click-change="rowChange_jd"
                @ClickOnLine="yj_viewForm_jd"
                :page="getList_jd.page"
                :pageSize="getList_jd.pageSize"
              />
              <pagination
                v-if="navigatepageNums_jd > 1"
                :info="queryCriteriaData_jd"
                :treelength="treelength"
                :total="queryCriteriaData_jd.total"
                :pageNum.sync="getList_jd.page"
                :limit.sync="getList_jd.pageSize"
                @pagination="getJdzlList(getList_jd)"
              />
            </div>
          </div>
        </el-dialog>
      </div>
      <!--监督指令弹框 查看 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_jdLook"
          v-loading="loadingEditDialog_jdLook"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div style="overflow-y: auto; margin-bottom: 20px; height: 100%">
              <div class="baseTitle">监督工作指令信息</div>
              <div class="publicForm" style="height: 350px; overflow-y: auto">
                <publicForm
                  ref="publicForm"
                  lableWidth="110px"
                  :formObj="FromShow_jd"
                  :formData="formData_jd"
                  :timestamp="formData_jd.fFileurl"
                  :fileList="fSourcefileList_jd"
                >
                </publicForm>
              </div>
              <div class="baseTitle" v-if="signFor_jd == 1 || signFor_jd == 2">
                {{ putAwayCon1 }}
              </div>
              <div
                class="publicForm"
                style="height: 70px; overflow-y: auto"
                v-if="signFor_jd == 1 || signFor_jd == 2"
              >
                <publicForm
                  ref="publicForm1"
                  lableWidth="110px"
                  :formObj="putAway1_jd"
                  :formData="formData_jd"
                >
                </publicForm>
              </div>

              <div class="baseTitle" v-if="signFor_jd == 2">
                {{ putAwayCon2 }}
              </div>
              <div
                class="publicForm"
                style="height: 70px; overflow-y: auto"
                v-if="signFor_jd == 2"
              >
                <publicForm
                  ref="publicForm2"
                  lableWidth="110px"
                  :formObj="putAway2_jd"
                  :formData="formData_jd"
                >
                </publicForm>
              </div>
              <div class="baseTitle">
                {{ review1 }}
              </div>
              <div class="publicForm" style="height: 100px; overflow-y: auto">
                <publicForm
                  ref="publicForm3"
                  lableWidth="110px"
                  :formObj="ReviewShow1_jd"
                  :formData="formData_jd"
                  :timestamp="formData_jd.fRecheckfile1"
                  :fileList="fRecheckfile1list_jd"
                >
                </publicForm>
              </div>
              <div style="height: 50px"></div>
            </div>
          </div>
        </el-dialog>
      </div>
      <!--工作沟通弹框--列表-->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_gt"
          v-loading="loadingEditDialog_gt"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div
              style="
                overflow-y: auto;
                margin-bottom: 20px;
                height: calc(100% - 31px);
                padding-top: 5px;
              "
            >
              <tableData
                :height="navigatepageNums_gt > 1 ? 'calc(100% - 50px)' : '100%'"
                :config="table_config_gt"
                :dataList="tableData_gt"
                @click-change="rowChange_gt"
                @ClickOnLine="yj_viewForm_gt"
                :page="getList_gt.page"
                :pageSize="getList_gt.pageSize"
              />
              <pagination
                v-if="navigatepageNums_gt > 1"
                :info="queryCriteriaData_gt"
                :treelength="treelength"
                :total="queryCriteriaData_gt.total"
                :pageNum.sync="getList_gt.page"
                :limit.sync="getList_gt.pageSize"
                @pagination="getGzgtList(getList_gt)"
              />
            </div>
          </div>
        </el-dialog>
      </div>
      <!--工作沟通弹框 查看 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible_gtLook"
          v-loading="loadingEditDialog_gtLook"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div style="overflow-y: auto; margin-bottom: 20px; height: 100%">
              <div class="baseTitle">质量工作在线沟通</div>
              <div class="publicForm" style="height: 180px; overflow-y: auto">
                <publicForm
                  ref="publicForm"
                  lableWidth="110px"
                  :formObj="FromShow_gt"
                  :formData="formData_gt"
                  :timestamp="formData_gt.fFileurl"
                  :fileList="fSourcefileList_gt"
                >
                </publicForm>
              </div>
              <div class="baseTitle">问题处理情况</div>
              <div class="publicForm" style="height: 100px; overflow-y: auto">
                <publicForm
                  ref="publicForm1"
                  lableWidth="110px"
                  :formObj="putAway_gt"
                  :formData="formData_gt"
                  :timestamp="formData_gt.fCheckfile"
                  :fileList="fCheckfileList_gt"
                >
                </publicForm>
              </div>

              <div style="height: 50px"></div>
            </div>
          </div>
        </el-dialog>
      </div>
      <custom-dialog
        @refreshList="refreshList"
        :currentRow="row"
        v-if="isShow"
        :dialogVisible="isShow"
        @close="closeDialog"
      ></custom-dialog>
    </div>
  </div>
</template>

<script>
import elBreadcrumb from "@/components/public/el-breadcrumb.vue";
import tree from "@/components/QualityGridManage/tree"; //左侧机构树
import TableData from "@/components/HntManage/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项

import CustomDialog from "@/components/QualityGridManage/logoff/index.vue";
import {
  isLogout
} from "@/utils/config"; //配置项jlButton
import {
  getXmCompanyTreeList, //左侧机构树接口
  getQualityDutyLists2, //主页面列表接口
  getQualityDutyByFid, //详情
  deleteQualityDutyBySystem, //删除

  // 巡查
  getWorkProcessPatrol2PageLists, //主页面列表接口
  getWorkProcessPatrol2ByFid, //详情
  // 巡查

  // 监督工作指令
  getWorkOrderExecutionReport2PageLists, //主页面列表接口
  getWorkOrderExecutionReport2ByFid, //详情
  // 监督工作指令

  // 工作沟通
  getWorkonlineCommunicatePageLists, //主页面列表接口
  getWorkonlineCommunicateByFid, //详情
  // 工作沟通
} from "@/api/request.js";

export default {
  name: "distribute",
  data() {
    return {
      name: "distribute", //按钮配置页面代号
      yj_view: null,
      yj_delete: null,
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      // 分页

      // 列表
      getList: {
        fCompanyid: "", // 左侧选中组织机构id
        page: 1, //页码
        pageSize: 20, //每页条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0代办 1已办 2表示列表页查询
        fQualitygridclass: "", // 上方查询条件质量网格
        fQualitygridtype: "", // 上方查询条件工程网格
        keyWord: "", // 责任人
        sublevel: 1,
      },
      fId: null, //当前行数据fId
      row: {}, //选中行
      loading: false, //列表转载
      table_config: formJs.table_config,
      tableData: [], //表格列表数据列表
      engineeringList: [
        { fItemName: "=请选择=", fItemValue: "=请选择=" },
        { fItemName: "施工项目部", fItemValue: "施工项目部" },
        { fItemName: "试验检验中心", fItemValue: "试验检验中心" },
        { fItemName: "监理单位", fItemValue: "监理单位" },
        { fItemName: "项目公司", fItemValue: "项目公司" },
        { fItemName: "分子公司", fItemValue: "分子公司" },
      ], //质量网格类型
      // 列表

      // 弹框·

      dialogTitle: "",
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示
      formObjShow: formJs.formObjLook,
      formData: formJs.formData,
      saveData: {},
      //  巡查
      dialogEditVisible_xc: false,
      loadingEditDialog_xc: false,
      getList_xc: {
        fCompanyid: "", // 左侧选中组织机构id
        fQualitygridclass: "", // 上方查询条件质量网格
        fQualitygridtype: "", // 上方查询条件工程网格
        fUnittype: "", //巡查单位类型（集团公司，分子公司，项目公司，监理单位）
        fStatus: "", //信息状态---编辑中（可编辑，可下发），待签收（可签收），执行中（可整改编辑），已结束
        warningLevel: "", // 预警状态 一级预警（4，黄色），二级预警（2，橙色），三级预警（3，红色），
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
      },
      fId_xc: null, //当前行数据fId
      row_xc: {}, //选中行
      table_config_xc: formJs.table_config_xc,
      tableData_xc: [], //表格列表数据列表
      navigatepageNums_xc: null, //是否显示分页
      queryCriteriaData_xc: {},
      // 弹框
      loadingEditDialog_xcLook: false, //弹框loading
      dialogEditVisible_xcLook: false, //新增弹框是否显示
      formObjShow_xc: formJs.formObjLook_xc, //质量巡查信息
      examineShow_xc: formJs.examineLook_xc, //巡查信息签收
      rectificationShow_xc: formJs.rectificationLook_xc, //整改信息回复
      formData_xc: formJs.formData_xc,
      fHandlefileList_xc: [], //上传文件
      fCompletionfilelist_xc: [], //回复文件
      // 弹框
      //  巡查

      // 监督工作指令
      // 列表
      getList_jd: {
        fCompanyid: "", // 左侧选中组织机构id
        page: 1, //页码
        pageSize: 20, //每页条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询 复查编辑页：待办3   已办4
        fQualitygridclass: "", // 上方查询条件质量网格
        fQualitygridtype: "", // 上方查询条件工程网格
      },
      fId_jd: null, //当前行数据fId
      row_jd: { fstatus: "" }, //选中行

      table_config_jd: formJs.table_config_jd,
      tableData_jd: [], //表格列表数据列表
      loadingEditDialog_jd: false, //弹框loading
      dialogEditVisible_jd: false, //新增弹框是否显示
      navigatepageNums_jd: null, //是否显示分页
      queryCriteriaData_jd: {},
      // 列表
      // 弹框
      FromShow_jd: formJs.FromShowLook1_jd, //下发
      FromShowLook1_jd: formJs.FromShowLook1_jd, //下发---查看
      FromShowLook2_jd: formJs.FromShowLook2_jd, //下发(2受检单位）---查看
      loadingEditDialog_jdLook: false, //弹框loading
      dialogEditVisible_jdLook: false, //新增弹框是否显示
      putAwayCon1: "受检单位1签收",
      putAway1_jd: formJs.putAwayLook1_jd, //签收
      putAwayCon2: "受检单位2签收",
      putAway2_jd: formJs.putAwayLook2_jd, //签收
      review1: "受检单位复查情况",
      ReviewShow1_jd: formJs.ReviewShowLook1_jd, //复查
      // review2: "受检单位2复查情况",
      // ReviewShow2: formJs.ReviewShowLook2, //复查
      formData_jd: formJs.formData_jd,
      fSourcefileList_jd: [], //指令信息相关资料
      fRecheckfile1list_jd: [], //复查相关资料1
      fRecheckfile2list_jd: [], //复查相关资料2
      signFor_jd: 0,
      // 弹框
      // 监督工作指令

      // 沟通
      // 列表
      navigatepageNums_gt: null, //是否显示分页
      queryCriteriaData_gt: {},
      getList_gt: {
        fCompanyid: "", // 左侧选中组织机构id
        fCheckunit: "", //涉及单位
        fCheckproject: "", //项目部名称
        fGridmantype: "", //网格员类别
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
      },
      fId_gt: null, //当前行数据fId
      row_gt: { fstatus: "" }, //选中行

      table_config_gt: formJs.table_config_gt,
      tableData_gt: [], //表格列表数据列表
      loadingEditDialog_gt: false, //弹框loading
      dialogEditVisible_gt: false, //新增弹框是否显示
      // 列表
      // 弹框
      loadingEditDialog_gtLook: false, //弹框loading
      dialogEditVisible_gtLook: false, //新增弹框是否显示

      FromShow_gt: formJs.FromShowLook_gt, //下发
      putAway_gt: formJs.putAwayLook_gt, //处理情况
      formData_gt: formJs.formData_gt,
      fSourcefileList_gt: [],
      fCheckfileList_gt: [],
      // 弹框
      // 沟通

      // 弹框

      // 机构树
      highlightBd: true, //左侧机构树停留背景色
      treelength: false, //左侧树显示隐藏
      checked: true, //查看下级按钮
      showName: "未选择公司",
      companyTree: "", //所有数据
      treeData: [], //左侧树状图数据
      defaultProps: {
        children: "children",
        label: "fShortname",
      },
      treeText: {
        companyId: null,
        userId: null,
      },
      checkData: [], //树状图默认选中id
      // 机构树
      userInfo: {}, //登录用户

      isShow: false, //是否显示弹框
    };
  },
  components: {
    elBreadcrumb,
    tree, //左侧组织机构数
    TableData, //主页面列表
    publicForm, //弹框表格
    Pagination, //分页
    CustomDialog, //停用
  },
  mounted() {
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
    this.getList.userId = this.userInfo.userId;

    if (JSON.parse(sessionStorage.getItem("Quality_treeCheck"))) {
      var id = JSON.parse(sessionStorage.getItem("Quality_treeCheck"));
      this.checkData = [id.fCompanyid];
    }

    this.getTree();
    this.btnRole(this.name);
    // this.table_config.thead[5]["callback"] = function (rowData) {
    //         let data = isLogout[rowData.isLogout];
    //         if (data) {
    //             return data.label;
    //         }
    //     };

        this.table_config.thead[5]["specialClass"] = function (rowData) {
            let data = isLogout[rowData.isLogout];
            if (data) {
                return data.className;
            }
        };
    this.table_config1.operation.cols = [
      {
        prop: "fstatus",
        type: "primary",
        handleRow: this.handleRow,
      },
    ];
    this.table_config1.operation["specialClass"] = function (rowData) {
      var color = null;
      if (rowData == "已结束") {
        color = "green !important";
      } else if (rowData == "已打回") {
        color = "red !important";
      }
      return color;
    };
  },
  methods: {
    // 停用
    yj_logoff() {
      if (this.userInfo.realName == "超级管理员") {
       
        if (this.fId != null) {
          this.isShow = true;
                } else {
                    this.$message.warning("请先选择需要停用的数据");
                }
      } else {
        this.$message.warning("该用户无法停用");
      }
    },
    refreshList() {
      //刷新列表
      this.$nextTick(() => {
        this.yj_searchForm(this.getList);
      });
    },
    closeDialog() {
      this.isShow = false;
    },
   
    // 停用
    //查看下级
    see() {
      if (this.checked == true) {
        this.getList.sublevel = 1;
      } else {
        this.getList.sublevel = 0;
      }
      this.yj_searchForm(this.getList);
    },
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });

        this.yj_view = btnStr.includes("yj_view");
        this.yj_delete = btnStr.includes("yj_delete");
      } else {
        this.yj_view = true;
        this.yj_delete = true;
      }
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      this.activeIndex = key;
    },
    // 左侧树结构
    getTree() {
      this.treeText.companyId = this.userInfo.companyId;
      this.treeText.userId = this.userInfo.userId;
      getXmCompanyTreeList(this.treeText)
        .then((res) => {
          if (res.errcode == 0) {
            var companyTree = res.data.userCompanyTreeList;
            this.treeData = this.commonJs.tranListToTreeData(companyTree);

            if (
              this.treeData[0].children == undefined &&
              this.treeData.length <= 1
            ) {
              this.treelength = false; //左侧组织机构是否显示
            } else {
              this.treelength = true;
            }

            if (this.checkData[0]) {
              this.showName = JSON.parse(
                sessionStorage.getItem("Quality_treeCheck")
              ).fShortname;
              this.getList.fCompanyid = this.checkData[0];
            } else {
              this.showName = this.treeData[0].fShortname; //当前点击组织机构名称
              this.getList.fCompanyid = this.treeData[0].fCompanyid; //当前点击组织机构ID
              this.checkData[0] = this.treeData[0].fCompanyid;
            }
            this.yj_searchForm(this.getList); // 调用主页面列表接口
            // 列表
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch(() => {
          return false;
        });
    },
    // 点击左侧机构树
    handleNodeClick(data) {
      this.showName = data.fShortname; //顶部显示机构名
      var sublevel = null;
      if (this.checked == true) {
        sublevel = 1;
      } else {
        sublevel = 0;
      }
      this.getList = {
        fCompanyid: data.fCompanyid, // 左侧选中组织机构id
        page: 1, //页码
        pageSize: 20, //每页条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0代办 1已办 不传或传空 表示列表页查询
        fQualitygridclass: "", // 上方查询条件质量网格
        fQualitygridtype: "", // 上方查询条件工程网格
        keyWord: "", // 责任人
        sublevel: sublevel,
      };
      this.yj_searchForm(this.getList);
    },
    // 获取列表数据
    yj_searchForm(id) {
      if (id.fQualitygridclass == "=请选择=") {
        id.fQualitygridclass = "";
      }
      // window.sessionStorage.setItem("scene_getList", JSON.stringify(id));
      this.row = { fstatus: "" }; //选中行
      this.loading = true;
      // getQualityDutyLists(id)
      getQualityDutyLists2(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.pageInfo.list;
            that.queryCriteriaData = res.data.pageInfo;
            that.navigatepageNums =
              that.queryCriteriaData.navigatepageNums.length;
            that.tableData.workOrderList = []; //工作指令
            that.tableData.workonlineCommunicateList = []; //沟通
            that.tableData.PatrolList = []; //巡查
          } else {
            this.$message.error("列表", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          this.loading = false;
        });
    },

    // 点击当前
    rowChange(val) {
      this.row = val;
      this.fId = val.fId;
    },

    // 点击查看
    yj_viewForm(row, label) {
      this.row = row;
      this.fId = row.fId;
      if (label == "质量网格类别") {
        this.editText(this.fId);
      } else if (label == "质量巡查") {
        this.getList_xc = {
          fCompanyid: "", // 左侧选中组织机构id
          fQualitygridclass: "", // 上方查询条件质量网格
          fQualitygridtype: "", // 上方查询条件工程网格
          fUnittype: "", //巡查单位类型（集团公司，分子公司，项目公司，监理单位）
          fStatus: "", //信息状态---编辑中（可编辑，可下发），待签收（可签收），执行中（可整改编辑），已结束
          warningLevel: "", // 预警状态 一级预警（4，黄色），二级预警（2，橙色），三级预警（3，红色），
          page: 1, // 当前页码
          pageSize: 20, // 每页显示条数
          userId: "", // 查询待办或已办时传 列表页查询不传
          modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
          fChargeuserid: this.row.fChargeuserid,
        };
        this.getXcList(this.getList_xc);
      } else if (label == "监督指令") {
        this.getList_jd = {
          fCompanyid: "", // 左侧选中组织机构id
          page: 1, // 当前页码
          pageSize: 20, // 每页显示条数
          userId: "", // 查询待办或已办时传 列表页查询不传
          modelType: "2", // 0-待办 1-已办 传2 表示列表页查询 复查编辑页：待办3   已办4
          fQualitygridclass: "", // 上方查询条件质量网格
          fQualitygridtype: "", // 上方查询条件工程网格
          fChargeuserid: this.row.fChargeuserid,
        };
        this.getJdzlList(this.getList_jd);
      } else if (label == "工作沟通") {
        this.getList_gt = {
          fCompanyid: "", // 左侧选中组织机构id
          fCheckunit: "", //涉及单位
          fCheckproject: "", //项目部名称
          fGridmantype: "", //网格员类别
          page: 1, // 当前页码
          pageSize: 20, // 每页显示条数
          userId: "", // 查询待办或已办时传 列表页查询不传
          modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
          fChargeuserid: this.row.fChargeuserid,
        };
        this.getGzgtList(this.getList_gt);
      }
    },

    // 查看
    editText(id) {
      this.dialogTitle = "查看";
      this.activeIndex = 0;
      if (id != "" && id != null) {
        this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        getQualityDutyByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog = false; //弹框loading
              this.formData = res.data.yjQmpMsQualitydutyManagement;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    // 删除
    yj_delForm(id) {
      if (id != "" && id != null) {
        if (this.userInfo.userId == "System") {
          this.$confirm("是否继续删除?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              var data = {
                userId: this.userInfo.userId, //当前操作用户userId 必须为System
                fId: id, //需删除数据的主键id
              };
              this.loading = true;
              deleteQualityDutyBySystem(data)
                .then((res) => {
                  if (res.errcode == 0) {
                    this.loading = false;
                    this.yj_searchForm(this.getList);
                    this.$message.success("删除成功");
                  } else {
                    this.$message.error("删除失败：" + res.msg);
                    this.loading = false;
                  }
                })
                .catch(() => {
                  console.log("删除失败");
                  this.loading = false;
                });
            })
            .catch(() => {
              this.$message.info("取消删除");
            });
        } else {
          return this.$message.error("该操作仅限管理员账户");
        }
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },
    getDate() {},
    // 获取页面容器高度
    getHeight() {
      // var h = document.documentElement.clientHeight; //获取页面可见高度
    },

    selectionChange() {},
    // 排序方法
    sortChange() {},

    // 巡查
    //列表
    getXcList(id) {
      var data = {
        fCompanyid: id.fCompanyid, // 左侧选中组织机构id
        fQualitygridclass: id.fQualitygridclass, //上方查询条件质量网格
        fQualitygridtype: id.fQualitygridtype, // 上方查询条件工程网格
        fUnittype: id.fUnittype, //巡查单位类型（集团公司，分子公司，项目公司，监理单位）
        fStatus: id.fStatus, //信息状态---编辑中（可编辑，可下发），待签收（可签收），执行中（可整改编辑），已结束
        warningLevel: id.warningLevel, // 预警状态 1：表示超期未结束 2：表示超期已结束
        page: id.page, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: id.userId, // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
        fChargeuserid: this.row.fChargeuserid,
      };
      this.dialogEditVisible_xc = true;
      this.loadingEditDialog_xc = true;

      getWorkProcessPatrol2PageLists(data)
        .then((res) => {
          if (res.errcode == 0) {
            this.dialogTitle = "巡查列表";
            var that = this;
            that.loadingEditDialog_xc = false;
            that.tableData_xc = res.data.pageInfo.list;
            that.queryCriteriaData_xc = res.data.pageInfo;
            that.navigatepageNums_xc =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loadingEditDialog_xc = false;
          }
        })
        .catch(() => {
          this.loadingEditDialog_xc = false;
        });
    },

    // 点击当前
    rowChange_xc(val) {
      this.row_xc = val;
      this.fId_xc = val.fId;
    },
    // 点击查看
    yj_viewForm_xc(row, label) {
      this.row_xc = row;
      this.fId_xc = row.fId;
      if (label == "巡查单位") {
        this.editText_xc(row.fId);
      }
    },
    // 查看
    editText_xc(id) {
      this.dialogTitle = "巡查详情";
      if (id != "" && id != null) {
        this.loadingEditDialog_xcLook = true; //弹框loading
        this.dialogEditVisible_xcLook = true;
        // getQualityDutyStationByFid({ fId: id })
        getWorkProcessPatrol2ByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog_xcLook = false; //弹框loading
              this.formData_xc = res.data.yjQmpMsWorkprocessPatrol;
              this.fHandlefileList_xc = res.data.fPatrolfileurllist;
              this.fCompletionfilelist_xc = res.data.fCompletionfilelist;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog_xcLook = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    // 巡查

    // 监督工作指令
    getJdzlList(id) {
      var data = {
        fCompanyid: id.fCompanyid, // 左侧选中组织机构id
        fQualitygridclass: id.fQualitygridclass, //上方查询条件质量网格
        fQualitygridtype: id.fQualitygridtype, // 上方查询条件工程网格
        page: id.page, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: id.userId, // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询 复查编辑页：待办3   已办4
        fChargeuserid: this.row.fChargeuserid,
      };
      this.dialogEditVisible_jd = true;
      this.loadingEditDialog_jd = true;
      this.row_jd = { fstatus: "" }; //选中行
      getWorkOrderExecutionReport2PageLists(data)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            this.dialogTitle = "监督指令列表";
            that.loadingEditDialog_jd = false;
            that.tableData_jd = res.data.pageInfo.list;
            that.queryCriteriaData_jd = res.data.pageInfo;
            that.navigatepageNums_jd =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loadingEditDialog_jd = false;
          }
        })
        .catch(() => {
          this.loadingEditDialog_jd = false;
        });
    },
    // 点击当前
    rowChange_jd(val) {
      this.row_jd = val;
      this.fId_jd = val.fId;
    },
    // 点击查看
    yj_viewForm_jd(row, label) {
      this.row_jd = row;
      this.fId_jd = row.fId;
      if (label == "下发指令单位") {
        this.editText_jd(this.fId_jd);
      }
    },
    // 查看
    editText_jd(id) {
      this.dialogTitle = "监督指令详情";
      if (id != "" && id != null) {
        this.loadingEditDialog_jdLook = true; //弹框loading
        this.dialogEditVisible_jdLook = true;

        getWorkOrderExecutionReport2ByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog_jdLook = false; //弹框loading
              var that = this;
              if (
                res.data.yjQmpMsWrokorderExecutionreport2.fCheckunit2 != "" &&
                res.data.yjQmpMsWrokorderExecutionreport2.fCheckunit2 != null
              ) {
                that.FromShow_jd = that.FromShowLook2_jd;
                this.putAwayCon1 = "受检单位1签收";
                this.putAwayCon2 = "受检单位2签收";

                this.signFor_jd = 2;
              } else {
                that.FromShow_jd = that.FromShowLook1_jd;
                this.putAwayCon1 = "受检单位签收";

                this.signFor_jd = 1;
              }

              that.fSourcefileList_jd = res.data.fFileurllist; //工作指令资料附件
              that.fRecheckfile1list_jd = res.data.fRecheckfile1list; //复查相关资料1
              that.fRecheckfile2list_jd = res.data.fRecheckfile2list; //复查相关资料2

              that.formData_jd = res.data.yjQmpMsWrokorderExecutionreport2;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog_jdLook = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    // 监督工作指令

    // 工作沟通列表
    getGzgtList(id) {
      var data = {
        fCompanyid: id.fCompanyid, // 左侧选中组织机构id
        fCheckunit: id.fCheckunit, //涉及单位
        fCheckproject: id.fCheckproject, //项目部名称
        fGridmantype: id.fGridmantype, //网格员类别
        page: id.page, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: id.userId, // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0-待办 1-已办 传2 表示列表页查询
        fChargeuserid: this.row.fChargeuserid,
      };
      this.dialogEditVisible_gt = true;
      this.loadingEditDialog_gt = true;
      this.row_gt = { fstatus: "" }; //选中行
      getWorkonlineCommunicatePageLists(data)
        .then((res) => {
          if (res.errcode == 0) {
            this.dialogTitle = "工作沟通列表";
            var that = this;
            that.loadingEditDialog_gt = false;
            that.tableData_gt = res.data.pageInfo.list;
            that.queryCriteriaData_gt = res.data.pageInfo;
            that.navigatepageNums_gt =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loadingEditDialog_xc = false;
          }
        })
        .catch(() => {
          this.loadingEditDialog_xc = false;
        });
    },
    // 点击当前
    rowChange_gt(val) {
      this.row_gt = val;
      this.fId_gt = val.fId;
    },
    // 点击查看
    yj_viewForm_gt(row, label) {
      this.row_gt = row;
      this.fId_gt = row.fId;
      if (label == "涉及单位") {
        this.editText_gt(this.fId_gt);
      }
    },
    // 查看
    editText_gt(id) {
      this.dialogTitle = "工作沟通详情";
      if (id != "" && id != null) {
        this.loadingEditDialog_gtLook = true; //弹框loading
        this.dialogEditVisible_gtLook = true;

        getWorkonlineCommunicateByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog_gtLook = false; //弹框loading
              var that = this;
              that.fSourcefileList_gt = res.data.fFileurllist; //工作指令资料附件
              that.fCheckfileList_gt = res.data.fCheckfilelist; //工作指令资料附件
              that.formData_gt = res.data.yjQmpMsWorkonlineCommunicate;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog_gtLook = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog_gtLook = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    // 工作沟通列表
  },
};
</script>

<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}

/* 弹框 */
.common /deep/.el-menu--horizontal > .el-menu-item.is-active {
  color: #409eff !important;
}

.publicForm .mouldForm /deep/ .el-form-item__content {
  margin-left: 125px !important;
}

/* 弹框 */
</style>
